import {setServer} from "@/utils/axios";
const request = setServer('');

// 查询楼宇
export function getBuilding(query) {
  return request({
    url: '/biotope/building/list',
    method: 'get',
    params: query
  })
}

// 查询楼宇详情
export function getBuildingDetail(id) {
  return request({
    url: '/biotope/building/'+id,
    method: 'get'
  })
}


// 通过小区查询楼宇
export function getBuildingByBiotopeId(id) {
  return request({
    url: '/biotope/building/list/'+id,
    method: 'get'
  })
}

// 查询楼宇
export function getAllBuilding(query) {
  return request({
    url: '/biotope/building/refer',
    method: 'get',
    params: query
  })
}

// 新增楼宇
export function addBuilding(query) {
  return request({
    url: '/biotope/building/',
    method: 'post',
    data: query
  })
}

// 修改楼宇
export function updateBuilding(query) {
  return request({
    url: '/biotope/building/',
    method: 'put',
    data: query
  })
}

// 删除楼宇
export function deleteBuilding(id) {
  return request({
    url: '/biotope/building/'+id,
    method: 'delete'
  })
}

export function getUnit(query) {
  return request({
    url: '/biotope/building/room/unit-grouppage',
    method: 'get',
    params: query
  })
}


// 查询房间
export function getRoom(query) {
  return request({
    url: '/biotope/building/room/list',
    method: 'get',
    params: query
  })
}

// 删除房间
export function deleteRoom(id) {
  return request({
    url: '/biotope/building/room/'+id,
    method: 'delete',
  })
}

// 批量删除房间
export function deleteSelectRoom(ids) {
  return request({
    url: '/biotope/building/room/batch',
    method: 'delete',
    params: ids
  })
}

// 通过楼宇查询单元
export function getUnitByBuildingId(id) {
  return request({
    url: '/biotope/building/room/unit/'+id,
    method: 'get'
  })
}

// 通过楼宇单元查询房间
export function getRoomByBuildingIdAndUnit(query) {
  return request({
    url: '/biotope/building/room/buildingid-unit',
    method: 'get',
    params: query
  })
}

// 修改房间资源码
export function updateRoomSn(query) {
  return request({
    url: '/biotope/building/room/label-id',
    method: 'put',
    params: query,
  })
}

// 添加房间
export function addRoom(query) {
  return request({
    url: '/biotope/building/room/insert-rooms',
    method: 'post',
    params: query,
  })
}

// 导出房间
export function exportRoom(data,type){
  return request({
    url:'/biotope/building/room/download',
    method: 'post',
    params: data,
    responseType:type
  })
}
